class Program {
	public static void main() {
		
		nqueen queen; 
		queen = new nqueen();
		queen.init(8);
		queen.search(0);
	}
}
class nqueen {
	Integer [] pos ;
	boolean [] used;
	boolean [] useddia;
	boolean [] usedbdia;
	int n ;
	int cnt ;
	public int init(int _n) {
		pre:_n>0 && _n<100;
		post:true;
		n = 8;
		pos =  new int[n];
		used = new boolean[n];
		useddia = new boolean[2*n];
		usedbdia = new boolean[2*n];
		return 0;
	}
	public int search(int step) {
		pre:step<n+1;
		post:true;
		if (step==n) {
			cnt = cnt+1;
			System.out.println(cnt);
			int i;
			i=0;
			while (i<n) {
				System.out.println(pos[i].toString());
				i=i+1;
			}
			System.out.println(888888);
		} else {
			int i;
			i=0;
			while (i<n) {
				if (!used[i] && !useddia[i+step] && !usedbdia[i-step+n]) {
					pos[step] = i;
					useddia[i+step] = true;
					usedbdia[i-step+n] = true;
					used[i] = true;
					search(step+1);
					useddia[i+step] = false;
					usedbdia[i-step+n] = false;
					used[i] = false;
				} else {
					i=i;
				}
				i=i+1;
			}		
		}
		return 0;
	}
}